<?php

namespace App\Http\Controllers\Admin\Finance\Repository;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Http\Controllers\Admin\Finance\Repository\Withdraw
 *
 * @property int $id
 * @property int|null $type 1.系统添加2.用户申请
 * @property float $price 金额
 * @property string|null $username
 * @property string|null $bank_id
 * @property int|null $member_id
 * @property int $status 1.待审批 2.已审批3.已拒绝 4.已打款 5.小额自动打款
 * @property string|null $refuse_reason
 * @property string|null $desc
 * @property \Carbon\Carbon|null $apply_time 申请时间
 * @property string|null $approve_time 审批时间
 * @property string|null $pay_time 汇款时间
 * @property string|null $refuse_time 拒绝时间
 * @property string|null $status_text
 * @property string|null $partner_trade_no
 * @property-read \App\Http\Controllers\Admin\Member\Repository\Member|null $member
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw whereApplyTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw whereApproveTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw whereBankId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw whereDesc($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw whereMemberId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw wherePartnerTradeNo($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw wherePayTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw wherePrice($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw whereRefuseReason($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw whereRefuseTime($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw whereStatusText($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw whereType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw whereUsername($value)
 * @mixin \Eloquent
 * @property float|null $poundage 手续费
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Http\Controllers\Admin\Finance\Repository\Withdraw wherePoundage($value)
 */
class Withdraw extends Model
{
    //
    protected $table = 'withdraw';
    protected $config;
    const CREATED_AT = 'apply_time';
    const UPDATED_AT = null;
    public function member(){
        return $this->belongsTo('App\Http\Controllers\Admin\Member\Repository\Member','member_id');
    }
    public  function  getStatusTextAttribute($key)
    {
        $config=$this->getConfig();

        return $config[$this->attributes['status']];
    }
    public function getConfig(){
      return  $this->config ? $this->config : $this->config=config('withdrawals.status');
    }
}
